<!-- 
历史记录页面
 * @Author: zuobufan
 * @Location: 安庆石化信息中心
 * @LastEditors: zuobufan
 * @LastEditTime: 2021-09-16 15:34:00
 -->
<template>
  <div>
    <!-- 历史记录 -->
    <div class="his-hot" v-show="isShowHistory">
      <div class="hd">
        <h4>历史记录</h4>
        <van-icon name="delete-o" @click="clearHistory" />
      </div>
      <div class="bd">
        <van-tag
          plain
          type="default"
          v-for="(item,index) in historyKeywordList"
          :key="index"
          @click="tagClick(item)"
        >{{item}}</van-tag>
      </div>
    </div>
    <!-- 热门搜索 -->
    <div class="his-hot">
      <div class="hd">
        <h4>热门搜索</h4>
      </div>
      <div class="bd">
        <van-tag
          plain
          type="default"
          v-for="(item,index) in hotKeywordList"
          :key="index"
          :class="item.is_hot? 'red':''"
           @click="tagClick(item.keyword)"
        >{{item.keyword}}</van-tag>
      </div>
    </div>
  </div>
</template>

<script>

  import {ClearHistory} from "@/request/api"
import { setTimeout } from 'timers';
export default {
  props: ["historyKeywordList", "hotKeywordList"],
  data() {
    return {
      isShowHistory:true,
    };
  },
  mounted() {},
  methods: {
      tagClick(val){
        //   console.log(val);
        this.$emit("tagClick",val)
          
      },
      clearHistory(){
        ClearHistory().then(res=>{
          if(res.errno == 0){
            console.log(res);
            this.$toast.success('成功文案');
            setTimeout(()=>{
              this.isShowHistory = false;
            },1000)
          }
        })
      }
  }
};
</script>
<style lang="less" scoped>
.his-hot {
  background-color: #fff;
  padding: 0.1rem;
  margin-bottom: 0.2rem;
  .hd {
    display: flex;
    justify-content: space-between;
    font-size: 0.24rem;
    margin-bottom: 0.05rem;
    h4 {
      font-size: 0.2rem;
    }
  }
  .bd {
    font-size: 0.14rem;
    .van-tag {
        margin-top: .1rem;
      margin-right: 0.1rem;
    }
    .red {
      color: red;
    }
  }
}
</style>